/**返回数组中两数之和等于目标值的下标 */
function test1 (numbers, target) {
    let map = new Map()
    let len = numbers.length
    for (let i = 0; i < len; i++) {
        let n = target - numbers[i]
        if (map.hasOwnProperty(n)) {
            return [map[n], i]
        }
        map[numbers[i]] = i
    }
    return []
}
var twoSum = function(nums, target) {
    const map = new Map()
    for (let i = 0; i < nums.length; i ++) {
      const otherIndex = map.get(target - nums[i])
      console.log('otherIndex', otherIndex)
      if (otherIndex !== undefined) return [otherIndex, i]
      map.set(nums[i], i)
    }
  };
  
var arr = [2, 7, 11, 15]
console.log(twoSum(arr, 9))
console.log(new [1,2,3].constructor(3))